<template>
  <div class="legend">
    <div class="legend-container">
      <div style="font-weight: bold;font-size: 16px;margin-bottom: 5px;">图例</div>
      <ul class="legend-list">
        <li v-for="(color, label) in items" :key="label" class="legend-item">
          <span class="legend-color" :style="{ backgroundColor: color }"></span>
          <span class="legend-label">{{ label }}</span>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
/**
 * 地图图例
 */

export default {
  name: 'MapLegend',
  props: {
    title: {
      type: String,
      default: "图例"
    },
    items: {
      type: Object,
      default: () => {}
    }
  }
}
</script>

<style scoped>
.legend {
  position: absolute;
  bottom: 25px;
  right: 15px;
  margin-left: 20px;
  padding: 15px;
  border: 1px solid #ccc;
  border-radius: 5px;
  background-color: #f9f9f9;
}

.legend-list {
  list-style: none;
  padding: 0;
  margin-bottom: 0;
}

.legend-item {
  display: flex;
  align-items: center;
  margin-bottom: 5px;
}

.legend-color {
  width: 20px;
  height: 20px;
  margin-right: 8px;
}

.legend-label {
  font-size: 14px;
}
</style>
